﻿using Abp.Domain.Uow;

namespace Hicap.AuthorizationServer.EntityFrameworkCore.Seed.Host
{
    public class InitialHostDbBuilder
    {
        private readonly AuthorizationServerDbContext _context;
        private readonly IUnitOfWorkManager _unitOfWorkManager;

        public InitialHostDbBuilder(AuthorizationServerDbContext context, IUnitOfWorkManager unitOfWorkManager)
        {
            _context = context;
            _unitOfWorkManager = unitOfWorkManager;
        }

        public void Create()
        {
            var role = new HostRoleAndUserCreator(_context, _unitOfWorkManager).Create();
            _context.SaveChanges();

            new AuthObjectCreator(_context).Create(role);
            _context.SaveChanges();
        }
    }
}